<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
String strId = request.getParameter("id"); 
String strName =  request.getParameter("name"); 
%>


<html>
  <head>
    <base href="<%=basePath%>">    
    <link rel="stylesheet" type="text/css" href="<%=path%>/js/ext/resources/css/ext-all.css">  
	<link rel="stylesheet" type="text/css" href="<%=path%>/js/ext/resources/css/edit-grid.css">  
	<script type="text/javascript" src="<%=path%>/js/ext/adapter/ext/ext-base.js"></script>
	<script type="text/javascript" src="<%=path%>/js/ext/ext-all.js"></script>
	<script type="text/javascript" src="<%=path%>/js/ext/DWRTreeLoader.js"></script>
	<script type="text/javascript" src="<%=path%>/js/ext/query-dwr-proxy.js"></script>	
	<script type="text/javascript" src="<%=path%>/js/ext/SearchField.js"></script>
	<script type='text/javascript' src='/btsm/dwr/interface/JFiberWeb.js'></script>
	<script type='text/javascript' src='/btsm/dwr/interface/JUsedFiberMapWeb.js'></script>
	<script type='text/javascript' src="<%=path%>/dwr/interface/JCommWeb.js"></script>
	<script type='text/javascript' src='/btsm/dwr/engine.js'></script>
	<script type='text/javascript' src='/btsm/dwr/util.js'></script>	
	<script type="text/javascript" src="<%=path%>/pages/station/LoadJs.js"></script>		
  </head>
<body> 
<div id="mainTabPanelDIV" style="width:100%;height:100%">
	<div id="baseTab"/> 
	<div id="outInfoTab"/> 
	<div id="routingTab"/> 	
	<div id="importTab"/> 	
	<div id="revTab"/>  
	<div id="nodeTab"/>  
	<div id="usedTab"/>  
	<div id="usedFiberMap"/>
</div>

<script type="text/javascript">

var dataToForm = {'ocName':"<%=strName%>"};	 		
var recordForAll = new Ext.data.Record(dataToForm);
var ocid = "<%=strId%>";
var firstPropertyRight;
var provZone;
function loadDate(ds,form){
	ds.on('beforeload', function() 
	{
		ds.baseParams = {id:"<%=strId%>"};
	});
	ds.load({params:{start:0,limit:17,id:"<%=strId%>"}});			
	form.getForm().loadRecord(recordForAll);	
}

function resetForm(form){
	form.getForm().loadRecord(recordForAll);	
}

function resetOutForm(form){ 
	var data = {'ocName':"<%=strName%>",'propertyRight':firstPropertyRight,'zone':provZone};	 		
	var record = new Ext.data.Record(data);
	form.getForm().loadRecord(record);	
}

function loadDateOther(ds,form,qtype){
	ds.on('beforeload', function() 
	{
		ds.baseParams = {queryType:qtype,id:"<%=strId%>"};
	});
	ds.load({params:{start:0,limit:17,id:"<%=strId%>"}});			
	form.getForm().loadRecord(recordForAll);	
}

function loadRouteOrPoleData(ds,qtype,isRoute){
	ds.on('beforeload', function() 
	{
		ds.baseParams = {query:qtype,id:"<%=strId%>",QUERY_TYPE:isRoute};
	});
	ds.load({params:{start:0,limit:17,id:"<%=strId%>",QUERY_TYPE:isRoute,query:qtype}}); 
}


var mainTabPanelDIV;
Ext.onReady(function()
{

	var viewport = new Ext.Viewport({
		layout:'border',
		frame:true,
		items:[ 
			{
				region: 'center',
				contentEl: 'mainTabPanelDIV',
				margins:'110 5 30 5',
				split: true,
				border: false	
			}]
		});


	mainTabPanelDIV = Ext.get("mainTabPanelDIV");
	
	
	
	var tabPanel = new Ext.TabPanel({
        renderTo:'mainTabPanelDIV',
		resizeTabs:true, // turn on tab resizing
        minTabWidth: 90,
        tabWidth:135,
		enableTabScroll:1,
		//height:450,
		height   : mainTabPanelDIV.getComputedHeight(),
		margins:'55 0 0 0',	
	    width:mainTabPanelDIV.getComputedWidth(),
        defaults:{autoHeight:true},
		items:[
	            {contentEl:'baseTab',title: '基本信息',id:1},
				{contentEl:'outInfoTab',title: '户外信息',id:2},
	            {contentEl:'routingTab',title: '纤芯使用情况',id:3},
				{contentEl:'revTab',title: '预留杆号',id:4},
				{contentEl:'nodeTab',title: '接头杆号',id:5},
				{contentEl:'importTab',title: '重要信息',id:6},
				{contentEl:'usedFiberMap',title: '纤芯使用对照',id:7}
        ]
    });
	
	tabPanel.activate(1); 
	
	tabPanel.on('tabchange',function()
	{ 		
		var selectedID = tabPanel.getActiveTab().id;
		switch(selectedID)
	    {
			case 1: 	
				
				break
			case 2: 	
				loadJs("<%=path%>/pages/fiber/out.js");
				loadDate(Outds,outForm);	
				break
			case 3:			
				loadJs("<%=path%>/pages/fiber/route.js");	
				loadDate(routDs,rForm);	
				break	 
			case 4:
				loadJs("<%=path%>/pages/fiber/res.js");	
				loadDateOther(resds,resForm,"isRes");	
				break	
			case 5:
				loadJs("<%=path%>/pages/fiber/isNode.js");	
				loadDateOther(nodeDs,nodeForm,"isNode");				
				break
			case 6:
				loadJs("<%=path%>/pages/fiber/import.js");
				loadDate(ids,iForm);				
				break	
			case 7:
				loadJs("<%=path%>/pages/fiber/usedfibermap.js");
				loadDate(uDs,uForm);				
				break			
		}
	})	
	
	var form = new Ext.FormPanel({       
        region     : 'center', 
		bodyStyle  : 'padding: 10px; background-color: #DFE8F6',
		labelWidth : 130,  
		height: 200,
		minSize: 200,
		maxSize: 200,
		frame:true,
		buttonAlign:'right',
		layout:'column',
        items: [
				{
					columnWidth:.33,
					layout: 'form',  
					labelWidth:100,	 
					labelAlign:'right',		
					items: [
						{
							xtype : 'hidden',
							name: 'id'
						},
						{
							xtype : 'hidden',
							name: 'ocid'
						},
						{
							xtype : 'hidden',
							name: 'fiberid'
						},{
							xtype:'textfield',
							fieldLabel: '中继段名称',
							name: 'ocName', 
							readOnly:true,
							width:200,
							value:'<%=strName%>' 	
						},{
							xtype:'textfield',
							fieldLabel: '基站名称',
							name: 'btsName',
							allowBlank:false,
							width:200,
							blankText :'请输入基站名称'	
						},{
							xtype:'textfield',
							fieldLabel: '光缆型号',
							name: 'ocLayType',
							allowBlank:false,
							width:200,
							blankText :'请输入光缆型号'	
						},
						{
							xtype:'numberfield',
							allowDecimals: true, 
							fieldLabel: '光缆芯数',
							width:200,
							name: 'ocNum'
						}]
				},{
					columnWidth:.33,
					layout: 'form',  
					labelWidth:80,	
					labelAlign:'right',				
					items: [
							{
								xtype:'numberfield',
								allowDecimals: true, 
								fieldLabel: '中继段长',
								width:200,
								name: 'ocLength'
							},{
								xtype:'numberfield',
								allowDecimals: true, 
								fieldLabel: '波长',
								name: 'wavelength',
								width:200,
								decimalPrecision:5,
								allowBlank:false,
								blankText :'请输入波长'	
							},{
								xtype:'numberfield',
								allowDecimals: true, 
								fieldLabel: '折射率',
								name: 'refractive',
								width:200,
								allowBlank:false,
								blankText :'请输入折射率'	
							}
						]
				},{
					columnWidth:.34,
					layout: 'form',  
					labelWidth:80,	 
					labelAlign:'right',		
					items: [
							{
								xtype:'textfield',
								fieldLabel: '仪表名称',
								width:200,
								name: 'instrumentName'
							},
							{
								xtype:'numberfield',
								fieldLabel: '邮政局',
								width:200,
								name: 'post'
							},
							{
								xtype:'textfield',
								fieldLabel: '测试人',
								width:200,
								name: 'tester'
							}
						]
					}
				
				
        ],
        buttons: [
				{
					text: '后退',
					handler:function()
					{
						history.go(-1);
					}
				},{
					text: '保存',
					handler:saveInfo
				},{
					text: '取消',
					handler:function()
					{
						form.getForm().reset(); 
					}
				}]
    });
	
	function saveInfo()
	{
		if (!form.getForm().isValid())
			return;	
		var f = form.getForm().getValues(false);
		FiberInfoBO = {};
		FiberInfoBO.id = f.id;
		FiberInfoBO.fiberid = f.id;
		FiberInfoBO.ocid = '<%=strId%>';
		FiberInfoBO.ocName = f.ocName;
		FiberInfoBO.btsName = f.btsName;
		FiberInfoBO.ocLayType = f.ocLayType;
		FiberInfoBO.ocNum = f.ocNum;
		FiberInfoBO.ocLength = f.ocLength;
		FiberInfoBO.wavelength = f.wavelength;
		FiberInfoBO.refractive = f.refractive;
		FiberInfoBO.instrumentName = f.instrumentName;
		FiberInfoBO.post = f.post;
		FiberInfoBO.tester = f.tester; 
		JFiberWeb.createFiberInfo(FiberInfoBO,function(data)
		{ 			
			if(data)
			{ 
				Ext.Msg.alert('成功',"操作成功！"); 
				//form.getForm().reset();
			}else
			{
				Ext.Msg.alert("失败","操作失败!");
			}	
		})
	}
	
	new Ext.Panel({
		width    : mainTabPanelDIV.getComputedWidth(),
		//height   : 378,
		height   : mainTabPanelDIV.getComputedHeight()-20,
		autoScroll:true,
		layout   : 'border',
		renderTo : 'baseTab',
		items    : [form ]
	});
	
	
	//初始化环境信息
	setTimeout(function(){
	 	JFiberWeb.getFiberInfoByOcId("<%=strId%>",function(obj) 
		{
			if(obj != null)
			{
				var data = {
							'id':obj.id,
							'fiberid':obj.fiberid,
							'ocid':obj.ocid,
							'ocName':obj.ocName,
							'btsName':obj.btsName,
							'ocLayType':obj.ocLayType,
							'ocNum':obj.ocNum,
							'ocLength':obj.ocLength,
							'wavelength':obj.wavelength,
							'refractive':obj.refractive,
							'instrumentName':obj.instrumentName,
							'post':obj.post,
							'tester':obj.tester,
							'testTime':obj.testTime
							
						   }; 
				var record = new Ext.data.Record(data);		    	     	    
				form.getForm().loadRecord(record);			   
			}
		})
	 },500);
	
	
})










</script>

</body>